#include "Window.h"

Window::Window()
:
    _width(0),
    _height(0),
    _title("no title"),
    _running(false)
{

}


Window::Window(int width, int height, std::string title)
:
    _width(width),
    _height(height),
    _title(title),
    _running(true)
{
    createWindow(_width, _height, _title);
}

void Window::createWindow(int width, int height, std::string title)
{
    _width = width;
    _height = height;
    _title = title;
    _running = true;

    _window.createWindow(sf::Videomode(_width, _height), _title, sf::Style::Default, sf::ContextSettings(32));
    _window.setVerticalSyncEnabled(true);
}

void Window::clear()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}

void Window::display()
{
    _window.display();
}

void Window::quit()
{
    _running = false;
}

void Window::update()
{
    while(_window.pollEvent(_event))
    {
        if(_event.type == sf::Event::Closed)
            quit();
    }
}

bool Window::running()
{
    return _running;
}

sf::Event& Window::getEvent()
{
    return _event;
}


int Window::getWidth()
{
    return _width;
}

int Window::getHeight()
{
    return _height;
}

